﻿using System.Collections.Generic;
using WikiPlex.Compilation;
using WikiPlex.Compilation.Macros;

namespace WikiPlex.Contrib.Macros
{
    /// <summary>
    /// Macro for [color:ff0000|Text that will appear red] sections
    /// </summary>
    /// <remarks>
    /// This accepts the color with or without #, but requires hex syntax always (color:red will not work)
    /// </remarks>
    public class ColoredTextMacro : IMacro
    {
        public string Id
        {
            get { return "Colored Text"; }
        }

        public IList<MacroRule> Rules
        {
            get
            {
                return new List<MacroRule>
                           {
                               new MacroRule(EscapeRegexPatterns.CurlyBraceEscape),
                               new MacroRule(@"(?i)(\[color:)(#?)(?>([0-9a-f]{6}\|[^\]]+))(\])",
                                             new Dictionary<int, string>
                                                 {
                                                     {1, ScopeName.Remove},
                                                     {2, ScopeName.Remove},
                                                     {3, ContribScopeNames.ColoredText},
                                                     {4, ScopeName.Remove}
                                                 })
                           };
            }
        }
    }
}
